package Demo;

import java.util.Scanner;

public class Demo04 {
    public static void main(String[] args) {
        // 键盘输入月份 日期，算出是今年的第几天

        Scanner s = new Scanner(System.in);
        System.out.println("请输入月份");
        int mouth = s.nextInt();
        System.out.println("请输入天数");
        int day = s.nextInt();

        int sumDays = 0;
        /*
         * if(mouth == 1){
         * 		sumDays = day;
         * }else if(mouth == 2){
         * 		sunDays = 31 + day
         * }.......
         *
         *
         * */

        /*
         * switch(mouth){
         * 	case 1:
         * 		sumDays = day;
         * 		break;
         * 	case 2:
         * 		sumDays = 31 + day;
         * 		break;
         * 	......
         *
         * 	case 12:
         * 		sumDays = 前11个月的和 + day；
         *
         * }
         * */

        //利用case穿透现象  举例 5月的第5天，就是前4个月天数和 加 day
        switch(mouth){
            case 12:
                sumDays += 30;
            case 11:
                sumDays += 31;
            case 10:
                sumDays += 30;
            case 9:
                sumDays += 31;
            case 8:
                sumDays += 31;
            case 7:
                sumDays += 30;
            case 6:
                sumDays += 31;
            case 5:
                sumDays += 3;
            case 4:
                sumDays += 31;
            case 3:
                sumDays += 29;
            case 2:
                sumDays += 31;
            case 1:
                sumDays += day;
                break;
        }

    }
}
